package com.scse.bms.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.scse.bms.domain.CommentVO;
import com.scse.bms.entity.CommentDO;
import com.scse.bms.mapper.CommentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Title: CommentServiceImpl
 * @Author: 吴赠禹
 * @Date: 2021/2/25 13:07
 * @Version: 1.0
 * @Description: TODO
 */

@Service
@Transactional(rollbackFor = Exception.class)
public class CommentServiceImpl extends ServiceImpl<CommentMapper, CommentDO> implements  CommentService {

    @Autowired
    private CommentMapper commentMapper;

    @Override
    public int agreement(CommentDO commentDO) {
        return commentMapper.approved(commentDO);
    }

    @Override
    public IPage<CommentDO> list(Page<?> page) {
        return commentMapper.selectAll(page);
    }

    @Override
    public int changeStatus(CommentDO commentDO) {
        return commentMapper.changeStatus(commentDO);
    }


    @Override
    public List<CommentVO> listForUserScan(Integer bookId) {
        return commentMapper.selectCommentsForFrontShow(bookId);
    }
}
